In this video, I'm going to reinforce the scripting skills from the last couple of videos by turning
my part right here into a patio for my shack.
So I'm using my first game.
You could use a fresh world.
Just go ahead and add a part.
But if you are using my first game, go to my part.
Did that move it script and disable it because we don't want our patio moving around.
All right, go to my part.
We're going to rename that to Patio and then hit this.
Plus, sign out a script.
And the script is going to be called Create Patio.
Cool.
I can go ahead and get rid of this print statement.
And then I remember how I made a comment.
Let's go ahead and review that.
Dash, dash, declare variables.
That's good.
A good habit to get into is the comment.
Let's go ahead and declare our variable.
So we have local our scope modifier saying we're only going to use this variable in this script.
I'll say patio, you can name this whatever you want as long as it makes sense.
And then I'll say script dot parent this gets a reference using this scripts parent then sticks it in
here so that we can modify the properties in the patio.
All right, let's go ahead and do a print statement.
Print statements are great for debugging so you can see where you are in the code.
We're only going to use two.
I'll say start creating patio, right?
And then at the end we'll say print, stop creating patio or something similar.
That way, if this never executes, we know there is something in the middle.
Might want to add another print statement.
All right, let's see.
We want to start out with our patio invisible and have it magically appear.
So let me go ahead.
If you'll notice that the spaces here, the interpreter just skips right over them.
Therefore, you you can put spaces if you want.
You can get rid of the spaces if you want.
I like it for readability.
I'm going to do this dash dash for a comment that's for me, not for the interpreter.
And I'm going to say, start with the patio.
Invisible.
All right.
How do we do that?
We have our patio variable.
We have transparency.
Remember, zero is fully opaque, one is fully transparent, which means it is invisible.
So we want it to be one.
All right.
Let's wait 6 seconds that so that we can enter the world and then we'll say patio.
Transparency equals zero and we'll see it magically appear.
So we should see these in the output window and we should see our patio up here.
Let's go to my game view output so we can see the output window.
You can see I played that once already.
Let's go ahead and get rid of it.
Go to home.
Start.
Creating patio.
But there's our part.
That's pretty cool.
Let's go ahead and add to it.
It's not really a great patio right now, is it?
Stop that and I'll put another I'll put another comment.
We can get rid of this so we have more space.
I'll put another comment in here and I'll say, change the size.
Of the patio.
Cool.
How do we do that?
Well, let's wait a second after we do our transparency, just so we can see different changes.
Right.
We'll come down here, and that will change our size.
So we need the patio variable.
We have size right here.
Look at that.
That's a vector three.
I don't know if you remember how to do vector three, but we're going to review it.
We'll say vector three.
Vector three holds three numbers.
No, because we've got to create a new one and then we'll make the patio 15 studs on the X and we'll
make it thin on the height.
Point two on the height.
15 studs on the Y.
Cool.
Let's go over to my first game, and then I notice right here the spawn location is here.
I don't want that interfering with my patio, so I hit this move.
I'm just going to move that over here.
Don't go too far, though.
That's how you get into the world.
All right.
Let's play this.
We can hit our view.
Look at the output window, see if we got any mistakes.
Make it a little bigger.
Go to home.
Hit the play.
Start creating patio.
Where is it at?
Bam.
Yeah, that's pretty cool.
But we need a closer.
How do we get it?
Closer.
Let's stop the game.
I want to take a look at the part right click on the part which is Patio now and then I'm going to look
at the position.
So this position right here and open it up.
We've got X, Y and Z.
I want the patio to be right in front of my shack.
So X is about 26.
Well, that's not quite right in front and it's not quite exact.
Z is going to be about zero.
If we want to know what this is.
Notice how the model selects.
Let's just select the floor by hitting alt and then clicking.
Look at that that position.
Zero on the x, zero on the z.
This Y is 10.25.
So that's the height of the terrain, which is ten studs, 0.25 is half of the size of the floor.
The floor is 0.5, 0.5 sides high.
So we want this.
The ten is good, the ten something is good.
The X is going to be positive.
Your shack might be might be rotated.
Right.
So you might have to change the X or the Z.
I don't have to change my Z.
Zero will be good.
And I want to make this one like 15 just to get a reference.
All right.
Let's go back to create Patio and now we are going to change the position.
Dash.
Dash changed the position of the patio.
And then once again, let's let's wait a second so we can see it happen.
So right after the size, let's go ahead and put a one second wait there.
I'm going to go down here.
Patio position.
That's a vector three two because it's three numbers.
We'll say vector three new and my four was zero, 10.5 and zero.
And then I notice that I need to move this on the x, the positive x right depending on where your shack
is located or oriented.
Right?
So we'll say 15 on the X, I'll keep this at 10.5.
Right.
And then 15 on No.
Zero on the Z that I'll put it directly in front.
So this number and this number you may have to mess around with based on the orientation of your shack.
I may be both of them if your shock isn't centered.
All right.
There we go.
We're going to watch it.
Cool.
Take a look at this, though.
Do you see that?
There's a little gap here.
That's because we made this thinner, but we kept it at the 0.5, 10.5 height.
You know what we could do?
We can anchor it.
Remember, we anchored it in another video and then have it plop down in place.
That would be kind of cool.
Let's go ahead and stop this.
And then this right here, we'll select the patio.
We'll go to Anchored and anchor it.
Now let's see it.
Plop down in place.
It's visible.
It got big.
It moved.
And then it plopped down in place.
You can kind of see it.
It's kind of hard.
I can get rid of this, but you can see it's right on the ground, but it is not anchored.
So it could be moved or what you can do is you can just get the height right there and then put it in.
But I like the way we're doing it now, I think looks kind of cool.
All right.
So we got our size.
We change that.
We change transparency.
Let's do something a little bit new.
Let's change the material to cobblestone.
All right.
If we look at our patio, we have these materials, we can open these up, but we can change them by
hand or we can change them by script.
If you'll notice, there is cobblestone in here.
Right there.
So these look like strings because they're words, but they're actually in an enumeration object.
I'll show you how to do that.
It's not really intuitive if you're new to programming.
So I'm going to say patio material.
Same property name there.
It gives you a hint.
If you go up here, it says E name dot material.
Oh, man.
What's that?
You know.
E name is short for enumeration.
It's a list.
So Roblox made a big list of stuff that you'll probably need to use in your code, and they use it in
their code in this enumeration.
And then there's a subcategory called material, and then you just have to do dot cobblestone.
Now you'll notice some of these base part are a part is a subcategory of base part.
So we could use anything for base part to reign is not a subcategory of base part, or at least not
close enough where you could use the material.
So you have to check if you use like air or terrain only.
We can't use air.
Right.
Foil we could use.
Oh, that's just base part.
You can't use a terrain of foil.
So just so you know that.
Anyway, you can play around with it.
You can learn by trial and error.
I did cobblestone.
I also want to wait though, for the turn.
So I'm going to do this.
Wait one second.
I want to see transitions.
So I put that right after the position so I can see my material change.
Let's go ahead and take a look.
We are almost completed our patio.
Here we go.
There we go.
Cobblestone, maybe.
I don't like that color of gray.
It's kind of gray.
Let's make it like a beige.
That way we can review color.
All right, now I'm going to put my weight statement in here before I forget weight.
I'm going to say that's my little comment.
Change the color of the patio.
Here we go.
I'll say patio.
Patio dot brick color.
So we have color and we have brick color.
I like to use brick color.
So brick color needs a brick color.
So we go ahead and do this.
Let's say equals brick color, brick color new.
And then we can actually spell out what we want from the color wheel.
I'm going to say beige.
I like beige.
There we are.
All done.
Let's check it.
Let's see if it works.
Play.
--, that's pretty cool.
Now we can do stuff with code.
We can actually make some pretty significant modifications.
We still can't create a part of the code yet, but we will.
And then we also want to be able to clone things, right?
Make things exactly the way we want it and then maybe make a whole bunch of them like zombies or something
like that.
That'd be cool.
I will see you in the next video.